//#include <csound\csound.hpp>
//#include <iostream>
#include "Screen.h"
#include "FragmentationDemo.h"
#include "TextureManager.h"
#include "PAInterface.h"

#include <math.h>
#include <random>
#include <iostream>
#undef main


#define NUM_SAMPLES 17640


int main(int argc, char** argv)
{
	/*
	Notes: To reset the scene, press 'R'
	During testing, it became apparent that when 
	this code was built on machines other than my own
	occasionally, the fragmentation fails and a single fragment
	is created that is inproperly physically simulated.
		Re-running the appilcation should solve this problem

	*/

	//Screen Init
	TheScreen::Instance()->CreateWindow(800, 600);	

	FragmentationDemo* demo = TheFragmentationDemo::Instance();
	PAInterface* audio = ThePAInterface::Instance();

	//Load Textures
	TheTextureManager::Instance()->Load("TexturePaths.txt");
	
	//Port Audio Init
	audio->Init(SAMPLE_RATE);
	audio->StartStream();


	while(true)
	{
		//Clear back buffer
		glClearColor(0, 0, 0, 1);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		
		demo->Update();
		demo->Draw();

		//Present back buffer to screen
		TheScreen::Instance()->Flip();
		
	}
	
	audio->StopStream();
	

	return 0;
}